package org.lds.logger.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.lds.logger.config.level.Level;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class LoggerEvent {
    private String name;
    private Level level;
    private String message;

    @Override
    public String toString() {
        return "{"
                + "\"name\":\""
                + StringUtils.trimToEmpty(name) + '\"'
                + ",\"level\":"
                + levelToString()
                + ",\"message\":\""
                + StringUtils.trimToEmpty(message) + '\"'
                + "}";
    }

    private String levelToString() {
        return level == null ? "" : level.name();
    }
}
